package com.fw.dao.impl;

import java.util.ArrayList;
import java.util.List;

import com.fw.dao.UserDao;

/**
 * 数据访问层实现类
 */
public class UserDaoImpl implements UserDao {
    //模拟数据库数据
    private  List<String> users = new ArrayList<String>();
    public UserDaoImpl() {
        users.add("张三");
        users.add("李四");
        users.add("王五");
    }
    @Override
    public List<String> findAllUsers() {
        return users;
    }

    @Override
    public String findUserById(int id) {
        if (id >= 0 && id < users.size()) {
            return users.get(id);
        }
        return "用户不存在";    
    }

    @Override
    public void addUser(String username) {
        users.add(username);
    }

}
